#pragma once
#include <winsock2.h>
#include <windows.h>
#include "mytypes.h"

namespace poly
{

class TCPSock
{
public:
	TCPSock();
	~TCPSock();
	void create();

	int host( int port, int backlog );
	int client( char* adr, int port );
	int accept( TCPSock& acceptSock );

	int setNonBlocking();
	int setBlocking();

	int send( char const * buffer, int len );
	int recv( int packSize = 0x10000 );
	int poll();

	void * buffer();
	int bufferSize();
	void clearBuffer();

	int close();
private:
	void initialize( SOCKET sock );
	SOCKET s;
	void * m_buffer;
	int len;
};

} // end of poly
